//
//  TeachManagementSegmentedView.m
//  Coach_HaiGeEr
//
//  Created by liuchen on 2018/9/26.
//  Copyright © 2018年 海格尔. All rights reserved.
//

#import "TeachManagementSegmentedView.h"
@interface TeachManagementSegmentedView()
@property (nonatomic,copy) NSArray *titleArr;
@property (nonatomic,weak) UILabel *lineLabel;
@end
@implementation TeachManagementSegmentedView

- (instancetype)initWithFrame:(CGRect)frame WithTitleArray:(NSArray *)titleArr{
    self = [super initWithFrame:frame];
    if (self) {
        //创建视图
        self.titleArr = titleArr;
        [self createSubView];
    }
    return self;
}

#pragma mark ==========创建视图==========
- (void)createSubView{
    self.backgroundColor = [UIColor whiteColor];
    UISegmentedControl *segment = [[UISegmentedControl alloc] initWithItems:self.titleArr];
    segment.selectedSegmentIndex = 0;//默认第一个segment被选中
    //segment.segmentedControlStyle = UISegmentedControlStyleBar;//设置
    segment.tintColor = RGBA(0, 212, 166, 1);
    segment.frame = CGRectMake(30*SCALEUNIT, self.frame.size.height*0.5-55*SCALEUNIT*0.5, 690*SCALEUNIT, 55*SCALEUNIT);
    //[segment addTarget:self action:@selector(changesegment:) forControlEvents:UIControlEventValueChanged];//监听事件,当控件值改变时调用
    _segment = segment;
    [self addSubview:self.segment];
    
    UILabel *lineLabel = [[UILabel alloc] initWithFrame:CGRectMake(25*SCALEUNIT, self.frame.size.height-2*SCALEUNIT, 700*SCALEUNIT, 2*SCALEUNIT)];
    lineLabel.backgroundColor = [UIColor colorWithHexString:@"#eeeeee"];
    _lineLabel = lineLabel;
    [self addSubview:self.lineLabel];
}

@end
